"use strict";
import * as React from 'react';
import { patchPostMessageJsCode } from "../constant";
const { View, WebView } = require('react-native');
const { connect } = require('react-redux');
class MyWebView extends React.Component {
    constructor(props, context) {
        super(props, context);
        this.state = {
            canGoBack: false,
            canGoForward: false,
            loading: false,
            title: '',
        };
    }
    onNavigationStateChange(e) {
        this.props.onNavigationStateChange && this.props.onNavigationStateChange(e);
    }
    onMessage(e, m) {
        if (this.props.onMessage) {
            this.props.onMessage(e.nativeEvent);
        }
    }
    onLoadEnd(e) {
        this.setState(Object.assign({}, e.nativeEvent));
        this.props.onLoadEnd && this.props.onLoadEnd(e);
    }
    render() {
        return (<View style={{ display: 'flex', flex: 1 }}>
                <WebView style={[{ display: 'flex', flex: 1 }, this.props.style]} injectedJavaScript={patchPostMessageJsCode} javaScriptEnabled domStorageEnabled onNavigationStateChange={this.onNavigationStateChange.bind(this)} onMessage={this.onMessage.bind(this)} onLoadEnd={this.onLoadEnd.bind(this)} {...this.props}/>
            </View>);
    }
}
export default MyWebView;
